/* const router = require("../routers/m1") */
const Router = require("koa-router")
const requireDirectory = require("require-directory")
// requireDirectory(module,`${process.cwd()}/routers/m1`,{visit:loadRouters})
const render = require("koa-art-template");
const static = require("koa-static")
function initManage(app){
    /* app.use(router.routes()) */
    // 加载/routers/m1下的文件时，会触发loadRouters函数
    requireDirectory(module,`${process.cwd()}/routers`,{
        visit:loadRouters
    })
    function loadRouters(obj){
        console.log(obj);
        if(obj instanceof Router){
            app.use(obj.routes())
        }
    }
    render(app,{
        root:`${process.cwd()}/views`,
        extname:'.html',
        debug:process.env.NODE_ENV !== 'production'
    })
    app.use(static(`${process.cwd()}/images`))
    app.use(static(`${process.cwd()}/static`))
}
module.exports = initManage